
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>内存模型 · Aivin开发笔记</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Aivin">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search-plus/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-local-video/video-js.min.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../../styles/website.css">
        
    

        
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="GC机制.html" />
    
    
    <link rel="prev" href="类加载机制.html" />
    

    
        <link rel="shortcut icon" href='../../assets/images/favicon.ico' type="image/x-icon">
    
    
        <link rel="bookmark" href='../../assets/images/favicon.ico' type="image/x-icon">
    
    
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    首页
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../doc/常用网站.html">
            
                <a href="../doc/常用网站.html">
            
                    
                    常用网站
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../常用软件/常用软件和框架.html">
            
                <a href="../常用软件/常用软件和框架.html">
            
                    
                    常用软件和框架
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../doc/开发规范.html">
            
                <a href="../doc/开发规范.html">
            
                    
                    开发规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../doc/开源软件.html">
            
                <a href="../doc/开源软件.html">
            
                    
                    开源软件和框架
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../doc/Android常用代码.html">
            
                <a href="../doc/Android常用代码.html">
            
                    
                    Android常用代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../源码阅读/源码阅读配置.html">
            
                <a href="../源码阅读/源码阅读配置.html">
            
                    
                    源码阅读
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../源码阅读/其他框架源码.html">
            
                <a href="../源码阅读/其他框架源码.html">
            
                    
                    其他框架源码
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../产品经理/产品经理.html">
            
                <a href="../产品经理/产品经理.html">
            
                    
                    产品经理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../设计模式/设计模式.html">
            
                <a href="../设计模式/设计模式.html">
            
                    
                    设计模式
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../设计模式/设计模式.html">
            
                <a href="../设计模式/设计模式.html">
            
                    
                    设计模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2" data-path="../设计模式/模式详解.html">
            
                <a href="../设计模式/模式详解.html">
            
                    
                    模式详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.3" data-path="../设计模式/mvc等.html">
            
                <a href="../设计模式/mvc等.html">
            
                    
                    mvc等
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../数据结构/常用数据结构.html">
            
                <a href="../数据结构/常用数据结构.html">
            
                    
                    基本算法
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" data-path="../数据结构/常用数据结构.html">
            
                <a href="../数据结构/常用数据结构.html">
            
                    
                    常用数据结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.2" data-path="../常用算法/算法术语.html">
            
                <a href="../常用算法/算法术语.html">
            
                    
                    算法术语
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.3" data-path="../常用算法/排序算法.html">
            
                <a href="../常用算法/排序算法.html">
            
                    
                    排序算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.4" data-path="../常用算法/查找算法.html">
            
                <a href="../常用算法/查找算法.html">
            
                    
                    查找算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.5" data-path="../常用算法/大数相加.html">
            
                <a href="../常用算法/大数相加.html">
            
                    
                    大数相加
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.6" data-path="../常用算法/集合的所有子集.html">
            
                <a href="../常用算法/集合的所有子集.html">
            
                    
                    获得集合的所有子集
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.7" data-path="../常用算法/扫描线种子填充算法.html">
            
                <a href="../常用算法/扫描线种子填充算法.html">
            
                    
                    扫描线种子填充算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.8" data-path="../常用算法/其他算法.html">
            
                <a href="../常用算法/其他算法.html">
            
                    
                    其他算法
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="原码补码反码.html">
            
                <a href="原码补码反码.html">
            
                    
                    Java部分
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.11.1" data-path="原码补码反码.html">
            
                <a href="原码补码反码.html">
            
                    
                    原码补码反码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.2" data-path="java常用代码.html">
            
                <a href="java常用代码.html">
            
                    
                    java常用代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.3" data-path="JVM详解.html">
            
                <a href="JVM详解.html">
            
                    
                    JVM详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.4" data-path="类加载机制.html">
            
                <a href="类加载机制.html">
            
                    
                    类加载机制
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.11.5" data-path="内存模型.html">
            
                <a href="内存模型.html">
            
                    
                    内存模型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.6" data-path="GC机制.html">
            
                <a href="GC机制.html">
            
                    
                    GC机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.7" data-path="对象内存布局.html">
            
                <a href="对象内存布局.html">
            
                    
                    对象内存布局
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.8" data-path="继承多态.html">
            
                <a href="继承多态.html">
            
                    
                    继承和多态
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.9" data-path="相等判断.html">
            
                <a href="相等判断.html">
            
                    
                    相等判断
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.10" data-path="Java容器类.html">
            
                <a href="Java容器类.html">
            
                    
                    Java容器类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.11" data-path="Java枚举.html">
            
                <a href="Java枚举.html">
            
                    
                    Java枚举
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.12" data-path="自定义异常.html">
            
                <a href="自定义异常.html">
            
                    
                    自定义异常
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.13" data-path="深度拷贝.html">
            
                <a href="深度拷贝.html">
            
                    
                    深度拷贝
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.14" data-path="泛型详解.html">
            
                <a href="泛型详解.html">
            
                    
                    泛型详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.15" data-path="线程详解.html">
            
                <a href="线程详解.html">
            
                    
                    线程详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.16" data-path="java注解.html">
            
                <a href="java注解.html">
            
                    
                    注解详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.17" data-path="数据解析.html">
            
                <a href="数据解析.html">
            
                    
                    数据解析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.18" data-path="java8新特性.html">
            
                <a href="java8新特性.html">
            
                    
                    Java8新特性
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="../android基础/android零散知识.html">
            
                <a href="../android基础/android零散知识.html">
            
                    
                    Android部分
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.12.1" data-path="../android基础/基础控件使用.html">
            
                <a href="../android基础/基础控件使用.html">
            
                    
                    基础控件使用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.2" data-path="../android基础/android零散知识.html">
            
                <a href="../android基础/android零散知识.html">
            
                    
                    Android零散知识
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.3" data-path="../android基础/android坐标体系.html">
            
                <a href="../android基础/android坐标体系.html">
            
                    
                    Android坐标体系
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.4" data-path="../android基础/APP的启动流程.html">
            
                <a href="../android基础/APP的启动流程.html">
            
                    
                    APP启动流程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.5" data-path="../android基础/View加载流程.html">
            
                <a href="../android基础/View加载流程.html">
            
                    
                    View加载流程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.6" data-path="../android基础/事件分发机制.html">
            
                <a href="../android基础/事件分发机制.html">
            
                    
                    事件分发机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.7" data-path="../android基础/控件绘制流程.html">
            
                <a href="../android基础/控件绘制流程.html">
            
                    
                    控件绘制流程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.8" data-path="../android基础/常用shape.html">
            
                <a href="../android基础/常用shape.html">
            
                    
                    常用shape
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.9" data-path="../android基础/进程通信.html">
            
                <a href="../android基础/进程通信.html">
            
                    
                    进程通信
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.10" data-path="../通信方式/通信方式详解.html">
            
                <a href="../通信方式/通信方式详解.html">
            
                    
                    通信方式详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.11" data-path="../android基础/Binder详解.html">
            
                <a href="../android基础/Binder详解.html">
            
                    
                    Binder详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.12" data-path="../android基础/Handler详解.html">
            
                <a href="../android基础/Handler详解.html">
            
                    
                    Handle详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.13" data-path="../android基础/Fragment详解.html">
            
                <a href="../android基础/Fragment详解.html">
            
                    
                    Fragment详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.14" data-path="../android基础/Activity详解.html">
            
                <a href="../android基础/Activity详解.html">
            
                    
                    Activity详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.15" data-path="../android基础/BroadcastReceiver.html">
            
                <a href="../android基础/BroadcastReceiver.html">
            
                    
                    BroadcastReceiver详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.16" data-path="../android基础/Service服务.html">
            
                <a href="../android基础/Service服务.html">
            
                    
                    Service详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.17" data-path="../android基础/动画详解.html">
            
                <a href="../android基础/动画详解.html">
            
                    
                    动画详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.18" data-path="../android基础/屏幕刷新机制.html">
            
                <a href="../android基础/屏幕刷新机制.html">
            
                    
                    屏幕刷新机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.19" data-path="../android基础/屏幕适配.html">
            
                <a href="../android基础/屏幕适配.html">
            
                    
                    屏幕适配
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.20" data-path="../android基础/图片加载详解.html">
            
                <a href="../android基础/图片加载详解.html">
            
                    
                    图片加载详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.21" data-path="../android基础/WebView详解.html">
            
                <a href="../android基础/WebView详解.html">
            
                    
                    WebView详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.22" data-path="../android基础/沉浸式.html">
            
                <a href="../android基础/沉浸式.html">
            
                    
                    沉浸式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.23" data-path="../android基础/相机模块.html">
            
                <a href="../android基础/相机模块.html">
            
                    
                    相机模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.24" data-path="../android基础/地图模块.html">
            
                <a href="../android基础/地图模块.html">
            
                    
                    地图模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.25" data-path="../android基础/Androidstudio插件开发.html">
            
                <a href="../android基础/Androidstudio插件开发.html">
            
                    
                    Androidstudio插件开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.26" data-path="../android基础/Apk插件化开发.html">
            
                <a href="../android基础/Apk插件化开发.html">
            
                    
                    Apk插件化开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.27" data-path="../android基础/App组件化开发.html">
            
                <a href="../android基础/App组件化开发.html">
            
                    
                    App组件化开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.28" data-path="../android基础/sdk开发.html">
            
                <a href="../android基础/sdk开发.html">
            
                    
                    sdk开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.29" data-path="../android基础/APP优化.html">
            
                <a href="../android基础/APP优化.html">
            
                    
                    APP优化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.30" data-path="../android基础/项目参数配置.html">
            
                <a href="../android基础/项目参数配置.html">
            
                    
                    项目参数配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.31" data-path="../android基础/App发布.html">
            
                <a href="../android基础/App发布.html">
            
                    
                    App发布
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.32" data-path="../android基础/Android外挂.html">
            
                <a href="../android基础/Android外挂.html">
            
                    
                    Android外挂
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.33" data-path="../android基础/Android字节码插桩.html">
            
                <a href="../android基础/Android字节码插桩.html">
            
                    
                    Android字节码插桩
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.34" data-path="../android基础/智能家居.html">
            
                <a href="../android基础/智能家居.html">
            
                    
                    智能家居
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="../python/python基础.html">
            
                <a href="../python/python基础.html">
            
                    
                    python部分
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.13.1" data-path="../python/python基础.html">
            
                <a href="../python/python基础.html">
            
                    
                    python基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.2" data-path="../python/python爬虫.html">
            
                <a href="../python/python爬虫.html">
            
                    
                    python爬虫
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="../gradle/Groovy.html">
            
                <a href="../gradle/Groovy.html">
            
                    
                    Groovy
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="../kotlin/kotlin部分.html">
            
                <a href="../kotlin/kotlin部分.html">
            
                    
                    kotlin部分
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16" data-path="../flutter/flutter部分.html">
            
                <a href="../flutter/flutter部分.html">
            
                    
                    flutter部分
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17" data-path="../native/ccpp.html">
            
                <a href="../native/ccpp.html">
            
                    
                    native部分
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.17.1" data-path="../native/Linux.html">
            
                <a href="../native/Linux.html">
            
                    
                    Linux
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.2" data-path="../native/ccpp.html">
            
                <a href="../native/ccpp.html">
            
                    
                    cCpp
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.3" data-path="../native/NDK.html">
            
                <a href="../native/NDK.html">
            
                    
                    NDK
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.4" data-path="../native/系统编译剪裁.html">
            
                <a href="../native/系统编译剪裁.html">
            
                    
                    系统编译剪裁
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.5" data-path="../native/音视频.html">
            
                <a href="../native/音视频.html">
            
                    
                    音视频
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.6" data-path="../native/音视频第三方库.html">
            
                <a href="../native/音视频第三方库.html">
            
                    
                    音视频第三方库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.7" data-path="../native/相关代码.html">
            
                <a href="../native/相关代码.html">
            
                    
                    相关代码
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.18" data-path="../server/服务器部分.html">
            
                <a href="../server/服务器部分.html">
            
                    
                    服务器部分
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.19" data-path="../webDev/web部分.html">
            
                <a href="../webDev/web部分.html">
            
                    
                    web部分
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.20" data-path="../人工智能/人工智能相关概念.html">
            
                <a href="../人工智能/人工智能相关概念.html">
            
                    
                    人工智能
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.21" data-path="../面试真题/极飞.html">
            
                <a href="../面试真题/极飞.html">
            
                    
                    面试真题
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >内存模型</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div class="search-plus" id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><li><span class="title-icon "></span><a href="#java&#x5185;&#x5B58;&#x6A21;&#x578B;"><b>1. </b>Java&#x5185;&#x5B58;&#x6A21;&#x578B;</a></li><li><span class="title-icon "></span><a href="#&#x8FD0;&#x884C;&#x65F6;&#x6570;&#x636E;&#x533A;&#x57DF;"><b>2. </b>&#x8FD0;&#x884C;&#x65F6;&#x6570;&#x636E;&#x533A;&#x57DF;</a></li><li><span class="title-icon "></span><a href="#&#x57FA;&#x672C;&#x6982;&#x5FF5;"><b>3. </b>&#x57FA;&#x672C;&#x6982;&#x5FF5;</a></li><ul><li><span class="title-icon "></span><a href="#&#x4E3B;&#x5185;&#x5B58;"><b>3.1. </b>&#x4E3B;&#x5185;&#x5B58;</a></li><li><span class="title-icon "></span><a href="#&#x5DE5;&#x4F5C;&#x5185;&#x5B58;"><b>3.2. </b>&#x5DE5;&#x4F5C;&#x5185;&#x5B58;</a></li><li><span class="title-icon "></span><a href="#&#x53EF;&#x89C1;&#x6027;"><b>3.3. </b>&#x53EF;&#x89C1;&#x6027;</a></li><li><span class="title-icon "></span><a href="#&#x6709;&#x5E8F;&#x6027;"><b>3.4. </b>&#x6709;&#x5E8F;&#x6027;</a></li><li><span class="title-icon "></span><a href="#&#x539F;&#x5B50;&#x64CD;&#x4F5C;-&#x3001;&#x539F;&#x5B50;&#x6027;"><b>3.5. </b>&#x539F;&#x5B50;&#x64CD;&#x4F5C; &#x3001;&#x539F;&#x5B50;&#x6027;</a></li><li><span class="title-icon "></span><a href="#&#x6307;&#x4EE4;&#x91CD;&#x6392;&#x5E8F;"><b>3.6. </b>&#x6307;&#x4EE4;&#x91CD;&#x6392;&#x5E8F;</a></li><li><span class="title-icon "></span><a href="#as-if-serial-&#x8BED;&#x4E49;"><b>3.7. </b>as-if-serial &#x8BED;&#x4E49;</a></li></ul><li><span class="title-icon "></span><a href="#8&#x5927;&#x539F;&#x5B50;&#x64CD;&#x4F5C;"><b>4. </b>8&#x5927;&#x539F;&#x5B50;&#x64CD;&#x4F5C;</a></li></ul></div><a href="#java&#x5185;&#x5B58;&#x6A21;&#x578B;" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h1 id="java&#x5185;&#x5B58;&#x6A21;&#x578B;"><a name="java&#x5185;&#x5B58;&#x6A21;&#x578B;" class="anchor-navigation-ex-anchor" href="#java&#x5185;&#x5B58;&#x6A21;&#x578B;"><i class="fa fa-link" aria-hidden="true"></i></a>1. Java&#x5185;&#x5B58;&#x6A21;&#x578B;</h1>
<pre><code class="lang-text">&#x5176;&#x4ED6;&#x8BED;&#x8A00;&#xFF0C;&#x4F8B;&#x5982;c/c++&#x76F4;&#x63A5;&#x4F7F;&#x7528;&#x4E86;&#x7269;&#x7406;&#x786C;&#x4EF6;&#x6216;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;&#x7684;&#x5185;&#x5B58;&#x6A21;&#x578B; &#xFF0C;
&#x7531;&#x4E8E;&#x4E0D;&#x540C;&#x5E73;&#x53F0;&#x4E0A;&#x5185;&#x5B58;&#x6A21;&#x578B;&#x7684;&#x5DEE;&#x5F02;&#x6027;&#xFF0C;&#x9700;&#x8981;&#x5F00;&#x53D1;&#x8005;&#x9488;&#x5BF9;&#x4E0D;&#x540C;&#x7684;&#x5E73;&#x53F0;&#x505A;&#x76F8;&#x5E94;&#x7684;&#x517C;&#x5BB9;&#x5904;&#x7406;&#x3002;
Java&#x5185;&#x5B58;&#x6A21;&#x578B;&#x662F;&#x4E3A;&#x4E86;&#x5C4F;&#x853D;&#x5404;&#x79CD;&#x786C;&#x4EF6;&#x548C;&#x7CFB;&#x7EDF;&#x7684;&#x8BBF;&#x95EE;&#x5DEE;&#x5F02;&#xFF0C;&#x8FBE;&#x5230;&#x4E00;&#x81F4;&#x7684;&#x5E76;&#x53D1;&#x6548;&#x679C;&#x3002;
&#x8FDB;&#x4E00;&#x6B65;&#x89E3;&#x51B3;&#x591A;&#x7EBF;&#x7A0B;&#x7F16;&#x7A0B;&#x4E2D;&#x7684;&#x7EBF;&#x7A0B;&#x5B89;&#x5168;&#x7B49;&#x95EE;&#x9898;&#x3002;
</code></pre>
<p><img src="https://gitee.com/hnyer/filesOfGitbook/raw/master/files/201801170848_osChina_p8.png" alt="">
<img src="https://gitee.com/hnyer/filesOfGitbook/raw/master/files/201801241435_osChina_&#x7EBF;&#x7A0B;&#x5185;&#x5B58;&#x548C;&#x4E3B;&#x5185;&#x5B58;.jpg" alt=""></p>
<h1 id="&#x8FD0;&#x884C;&#x65F6;&#x6570;&#x636E;&#x533A;&#x57DF;"><a name="&#x8FD0;&#x884C;&#x65F6;&#x6570;&#x636E;&#x533A;&#x57DF;" class="anchor-navigation-ex-anchor" href="#&#x8FD0;&#x884C;&#x65F6;&#x6570;&#x636E;&#x533A;&#x57DF;"><i class="fa fa-link" aria-hidden="true"></i></a>2. &#x8FD0;&#x884C;&#x65F6;&#x6570;&#x636E;&#x533A;&#x57DF;</h1>
<p><img src="https://gitee.com/hnyer/filesOfGitbook/raw/master/files/201801170848_osChina_p7.png" alt="aivin"> <br>
(&#x7EFF;&#x8272;&#x90E8;&#x5206;&#x662F;&#x6BCF;&#x4E2A;&#x7EBF;&#x7A0B;&#x79C1;&#x6709;&#x7684;&#xFF0C;&#x767D;&#x8272;&#x90E8;&#x5206;&#x662F;&#x7EBF;&#x7A0B;&#x5171;&#x4EAB;&#x7684;)</p>
<pre><code class="lang-text">&#x5206;&#x4E3A;5&#x5757;&#x5185;&#x5B58;&#x7A7A;&#x95F4;&#x3002;
&#x9644;&#xFF1A;&#x6808;&#x662F;&#x8FD0;&#x884C;&#x7684;&#x5355;&#x4F4D;&#xFF0C;&#x800C;&#x5806;&#x662F;&#x5B58;&#x50A8;&#x7684;&#x5355;&#x5143;&#x3002;

// 1&#x3001;&#x7A0B;&#x5E8F;&#x8BA1;&#x6570;&#x5668;
&#x5F53;&#x524D;&#x7EBF;&#x7A0B;&#x6240;&#x6267;&#x884C;&#x7684;&#x5B57;&#x8282;&#x7801;&#x7684;&#x884C;&#x53F7;&#x6307;&#x793A;&#x5668;&#x3002;&#x7528;&#x6765;&#x8BB0;&#x5F55;&#x7A0B;&#x5E8F;&#x8FD0;&#x884C;&#x5230;&#x54EA;&#x91CC;&#x4E86;&#xFF0C;&#x4E0B;&#x4E00;&#x6B65;&#x53C8;&#x8BE5;&#x6267;&#x884C;&#x54EA;&#x4E00;&#x6B65;&#x64CD;&#x4F5C;&#x3002;

// 2&#x3001;&#x672C;&#x5730;&#x65B9;&#x6CD5;&#x6808;
&#x5B58;&#x50A8;&#x672C;&#x5730;&#x65B9;&#x6CD5;&#x6267;&#x884C;&#x8FC7;&#x7A0B;&#x4E2D;&#x7684;&#x6808;&#x6570;&#x636E;&#x3002;

// 3&#x3001;JVM&#x6808;&#xFF08;Java&#x6808;&#xFF09;
&#x5B58;&#x653E;&#x4E00;&#x4E2A;Java&#x7EBF;&#x7A0B;&#x7684;&#x8FD0;&#x884C;&#x72B6;&#x6001;&#x3002;

//  4&#x3001;&#x5806;
&#x5B58;&#x653E;&#x8FD0;&#x884C;&#x65F6;&#x4EA7;&#x751F;&#x7684;&#x5BF9;&#x8C61;&#x7684;&#x3002;Java&#x53EA;&#x80FD;&#x5728;&#x5806;&#x4E2D;&#x5B58;&#x653E;&#x5BF9;&#x8C61;

//  5&#x3001;&#x65B9;&#x6CD5;&#x533A;
&#x65B9;&#x6CD5;&#x533A;&#x4E3B;&#x8981;&#x662F;&#x7528;&#x6765;&#x5B58;&#x7C7B;&#x578B;&#x6570;&#x636E;&#x7684;&#xFF0C;&#x4E0E;&#x7C7B;&#x578B;&#x76F8;&#x5173;&#x7684;&#x4E1C;&#x897F;&#xFF0C;&#x6BD4;&#x5982;&#x5E38;&#x91CF;&#xFF0C;&#x9759;&#x6001;&#x53D8;&#x91CF;&#x3002;
&#x6CE8;&#xFF1A;&#x8FD0;&#x884C;&#x65F6;&#x5E38;&#x91CF;&#x6C60;&#x662F;&#x65B9;&#x6CD5;&#x533A;&#x7684;&#x4E00;&#x90E8;&#x5206;&#xFF0C;&#x7528;&#x6765;&#x5B58;&#x653E;&#x7F16;&#x8BD1;&#x5668;&#x751F;&#x6210;&#x7684;&#x5404;&#x79CD;&#x5B57;&#x9762;&#x91CF;&#x548C;&#x7B26;&#x53F7;&#x5F15;&#x7528;&#x3002;
</code></pre>
<h1 id="&#x57FA;&#x672C;&#x6982;&#x5FF5;"><a name="&#x57FA;&#x672C;&#x6982;&#x5FF5;" class="anchor-navigation-ex-anchor" href="#&#x57FA;&#x672C;&#x6982;&#x5FF5;"><i class="fa fa-link" aria-hidden="true"></i></a>3. &#x57FA;&#x672C;&#x6982;&#x5FF5;</h1>
<h2 id="&#x4E3B;&#x5185;&#x5B58;"><a name="&#x4E3B;&#x5185;&#x5B58;" class="anchor-navigation-ex-anchor" href="#&#x4E3B;&#x5185;&#x5B58;"><i class="fa fa-link" aria-hidden="true"></i></a>3.1. &#x4E3B;&#x5185;&#x5B58;</h2>
<pre><code class="lang-text">&#x8FDB;&#x7A0B;&#x5185;&#x5B58;&#x3002;
&#x6240;&#x6709;&#x7EBF;&#x7A0B;&#x5171;&#x4EAB;&#x4E3B;&#x5185;&#x5B58;&#x3002;
</code></pre>
<h2 id="&#x5DE5;&#x4F5C;&#x5185;&#x5B58;"><a name="&#x5DE5;&#x4F5C;&#x5185;&#x5B58;" class="anchor-navigation-ex-anchor" href="#&#x5DE5;&#x4F5C;&#x5185;&#x5B58;"><i class="fa fa-link" aria-hidden="true"></i></a>3.2. &#x5DE5;&#x4F5C;&#x5185;&#x5B58;</h2>
<pre><code class="lang-text">&#x7EBF;&#x7A0B;&#x5185;&#x5B58;&#x3002;
&#x6BCF;&#x4E2A;&#x7EBF;&#x7A0B;&#x90FD;&#x6709;&#x81EA;&#x5DF1;&#x7684;&#x6267;&#x884C;&#x7A7A;&#x95F4;(&#x5373;&#x5DE5;&#x4F5C;&#x5185;&#x5B58;)&#xFF0C;&#x7EBF;&#x7A0B;&#x6267;&#x884C;&#x7684;&#x65F6;&#x5019;&#x7528;&#x5230;&#x67D0;&#x53D8;&#x91CF;&#xFF0C;
&#x9996;&#x5148;&#x8981;&#x5C06;&#x53D8;&#x91CF;&#x4ECE;&#x4E3B;&#x5185;&#x5B58;&#x62F7;&#x8D1D;&#x7684;&#x81EA;&#x5DF1;&#x7684;&#x5DE5;&#x4F5C;&#x5185;&#x5B58;&#x7A7A;&#x95F4;&#xFF0C;
&#x7136;&#x540E;&#x5BF9;&#x53D8;&#x91CF;&#x8FDB;&#x884C;&#x64CD;&#x4F5C;&#xFF1A;&#x8BFB;&#x53D6;&#xFF0C;&#x4FEE;&#x6539;&#xFF0C;&#x8D4B;&#x503C;&#x7B49;&#xFF0C;&#x8FD9;&#x4E9B;&#x5747;&#x5728;&#x5DE5;&#x4F5C;&#x5185;&#x5B58;&#x5B8C;&#x6210;&#xFF0C;
&#x64CD;&#x4F5C;&#x5B8C;&#x6210;&#x540E;&#x518D;&#x5C06;&#x53D8;&#x91CF;&#x5199;&#x56DE;&#x4E3B;&#x5185;&#x5B58;&#xFF1B;
</code></pre>
<h2 id="&#x53EF;&#x89C1;&#x6027;"><a name="&#x53EF;&#x89C1;&#x6027;" class="anchor-navigation-ex-anchor" href="#&#x53EF;&#x89C1;&#x6027;"><i class="fa fa-link" aria-hidden="true"></i></a>3.3. &#x53EF;&#x89C1;&#x6027;</h2>
<pre><code class="lang-text">&#x6307;&#x5F53;&#x4E00;&#x4E2A;&#x7EBF;&#x7A0B;&#x4FEE;&#x6539;&#x4E86;&#x5171;&#x4EAB;&#x53D8;&#x91CF;&#x7684;&#x503C;&#xFF0C;&#x5176;&#x4ED6;&#x7EBF;&#x7A0B;&#x80FD;&#x591F;&#x7ACB;&#x5373;&#x5F97;&#x77E5;&#x8FD9;&#x4E2A;&#x4FEE;&#x6539;&#x3002;

&#x5404;&#x4E2A;&#x7EBF;&#x7A0B;&#x90FD;&#x4ECE;&#x4E3B;&#x5185;&#x5B58;&#x4E2D;&#x83B7;&#x53D6;&#x6570;&#x636E;&#xFF0C;&#x7EBF;&#x7A0B;&#x4E4B;&#x95F4;&#x6570;&#x636E;&#x662F;&#x4E0D;&#x53EF;&#x89C1;&#x7684;&#xFF1B;
&#x4F8B;&#x5982;&#xFF0C;&#x4E3B;&#x5185;&#x5B58; &#x53D8;&#x91CF;A &#x539F;&#x59CB;&#x503C;&#x4E3A;1&#xFF0C;&#x7EBF;&#x7A0B;1&#x4ECE;&#x4E3B;&#x5185;&#x5B58;&#x53D6;&#x51FA; &#x53D8;&#x91CF;A&#xFF0C;&#x4FEE;&#x6539;A&#x7684;&#x503C;&#x4E3A;2&#xFF0C;
&#x5728;&#x7EBF;&#x7A0B;1&#x672A;&#x5C06;&#x53D8;&#x91CF;A&#x5199;&#x56DE;&#x4E3B;&#x5185;&#x5B58;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x7EBF;&#x7A0B;2&#x62FF;&#x5230;&#x53D8;&#x91CF;A&#x7684;&#x503C;&#x4ECD;&#x7136;&#x4E3A;1&#xFF1B;

&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x4F7F;&#x7528; volatile &#x6216; synchronized &#x7B49;&#x673A;&#x5236; &#x4FDD;&#x8BC1;&#x53EF;&#x89C1;&#x6027;&#x3002;
</code></pre>
<h2 id="&#x6709;&#x5E8F;&#x6027;"><a name="&#x6709;&#x5E8F;&#x6027;" class="anchor-navigation-ex-anchor" href="#&#x6709;&#x5E8F;&#x6027;"><i class="fa fa-link" aria-hidden="true"></i></a>3.4. &#x6709;&#x5E8F;&#x6027;</h2>
<pre><code class="lang-text">&#x5982;&#x679C;&#x5728;&#x672C;&#x7EBF;&#x7A0B;&#x5185;&#x89C2;&#x5BDF;&#xFF0C;&#x6240;&#x6709;&#x7684;&#x64CD;&#x4F5C;&#x90FD;&#x662F;&#x6709;&#x5E8F;&#x7684;&#xFF1B;
&#x6307;&quot;&#x7EBF;&#x7A0B;&#x5185;&#x8868;&#x73B0;&#x4E3A;&#x4E32;&#x884C;&#x7684;&#x8BED;&#x4E49;&quot;

&#x5982;&#x679C;&#x5728;&#x4E00;&#x4E2A;&#x7EBF;&#x7A0B;&#x4E2D;&#x89C2;&#x5BDF;&#x53E6;&#x4E00;&#x4E2A;&#x7EBF;&#x7A0B;&#xFF0C;&#x6240;&#x6709;&#x7684;&#x64CD;&#x4F5C;&#x90FD;&#x662F;&#x65E0;&#x5E8F;&#x7684;&#x3002;
&#x6307;&quot;&#x6307;&#x4EE4;&#x91CD;&#x6392;&#x5E8F;&quot;&#x73B0;&#x8C61;&#x548C;&quot;&#x5DE5;&#x4F5C;&#x5185;&#x5B58;&#x4E0E;&#x4E3B;&#x5185;&#x5B58;&#x540C;&#x6B65;&#x5EF6;&#x8FDF;&quot;&#x73B0;&#x8C61;&#x3002;

Java&#x63D0;&#x4F9B;&#x4E86; volatile &#x548C; synchronized &#x6765;&#x4FDD;&#x8BC1;&#x6709;&#x5E8F;&#x6027; &#xFF0C;
volatile &#x672C;&#x8EAB;&#x5305;&#x542B;&#x7981;&#x6B62;&#x6307;&#x4EE4;&#x91CD;&#x6392;&#x5E8F;&#x7684;&#x8BED;&#x4E49;&#xFF0C;
synchronized &#x5219;&#x662F;&#x7531;&quot;&#x4E00;&#x4E2A;&#x53D8;&#x91CF;&#x5728;&#x540C;&#x4E00;&#x4E2A;&#x65F6;&#x523B;&#x53EA;&#x5141;&#x8BB8;&#x4E00;&#x6761;&#x7EBF;&#x7A0B;&#x5BF9;&#x5176;&#x8FDB;&#x884C;lock&#x64CD;&#x4F5C;&quot;&#x7684;&#x89C4;&#x5219;&#x6765;&#x83B7;&#x5F97;&#x3002;
</code></pre>
<h2 id="&#x539F;&#x5B50;&#x64CD;&#x4F5C;-&#x3001;&#x539F;&#x5B50;&#x6027;"><a name="&#x539F;&#x5B50;&#x64CD;&#x4F5C;-&#x3001;&#x539F;&#x5B50;&#x6027;" class="anchor-navigation-ex-anchor" href="#&#x539F;&#x5B50;&#x64CD;&#x4F5C;-&#x3001;&#x539F;&#x5B50;&#x6027;"><i class="fa fa-link" aria-hidden="true"></i></a>3.5. &#x539F;&#x5B50;&#x64CD;&#x4F5C; &#x3001;&#x539F;&#x5B50;&#x6027;</h2>
<pre><code class="lang-text">&#x662F;&#x6307;&#x4E0D;&#x4F1A;&#x88AB;&#x7EBF;&#x7A0B;&#x8C03;&#x5EA6;&#x673A;&#x5236;&#x6253;&#x65AD;&#x7684;&#x64CD;&#x4F5C;&#x673A;&#x5236;&#x3002;
&#x8FD9;&#x79CD;&#x64CD;&#x4F5C;&#x4E00;&#x65E6;&#x5F00;&#x59CB;&#xFF0C;&#x5C31;&#x4E00;&#x76F4;&#x8FD0;&#x884C;&#x5230;&#x7ED3;&#x675F;&#xFF0C;&#x4E2D;&#x95F4;&#x4E0D;&#x4F1A;&#x6709;&#x4EFB;&#x4F55; context switch &#xFF08;&#x5207;&#x6362;&#x5230;&#x53E6;&#x4E00;&#x4E2A;&#x7EBF;&#x7A0B;&#xFF09;&#x3002;
&#x6839;&#x636E;java &#x5B9A;&#x4E49;&#xFF0C;&#x539F;&#x5B50;&#x64CD;&#x4F5C;&#x662F;&#x4E0D;&#x4F1A;&#x88AB;&#x6253;&#x65AD;&#x5730;&#x7684;&#x64CD;&#x4F5C;&#xFF0C;&#x56E0;&#x6B64;&#x88AB;&#x8BA4;&#x4E3A;&#x662F;&#x7EBF;&#x7A0B;&#x5B89;&#x5168;&#x7684;&#x3002;
java&#x4E2D;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x9501;&#x548C;&#x5FAA;&#x73AF;CAS&#x7684;&#x65B9;&#x5F0F;&#x6765;&#x5B9E;&#x73B0;&#x539F;&#x5B50;&#x64CD;&#x4F5C;&#x3002;
</code></pre>
<h2 id="&#x6307;&#x4EE4;&#x91CD;&#x6392;&#x5E8F;"><a name="&#x6307;&#x4EE4;&#x91CD;&#x6392;&#x5E8F;" class="anchor-navigation-ex-anchor" href="#&#x6307;&#x4EE4;&#x91CD;&#x6392;&#x5E8F;"><i class="fa fa-link" aria-hidden="true"></i></a>3.6. &#x6307;&#x4EE4;&#x91CD;&#x6392;&#x5E8F;</h2>
<pre><code class="lang-text">&#x5373;&#x751F;&#x6210;&#x7684;&#x673A;&#x5668;&#x6307;&#x4EE4;&#x4E0E;&#x5B57;&#x8282;&#x7801;&#x6307;&#x4EE4;&#x987A;&#x5E8F;&#x4E0D;&#x4E00;&#x81F4;&#x3002;

&#x4E3A;&#x4EC0;&#x4E48;&#x4F1A;&#x6709;&#x91CD;&#x6392;&#x5E8F;?
&#x4E3A;&#x4E86;&#x63D0;&#x9AD8;&#x6267;&#x884C;&#x6548;&#x7387;&#xFF0C;&#x76EE;&#x524D;&#x5927;&#x591A;&#x6570;&#x73B0;&#x4EE3;&#x5FAE;&#x5904;&#x7406;&#x5668;&#x90FD;&#x4F1A;&#x91C7;&#x7528;&#x5C06;&#x6307;&#x4EE4;&#x4E71;&#x5E8F;&#x6267;&#x884C;&#x3002;
&#x5728;&#x6761;&#x4EF6;&#x5141;&#x8BB8;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x76F4;&#x63A5;&#x8FD0;&#x884C;&#x5F53;&#x524D;&#x6709;&#x80FD;&#x529B;&#x7ACB;&#x5373;&#x6267;&#x884C;&#x7684;&#x540E;&#x7EED;&#x6307;&#x4EE4;&#xFF0C;&#x907F;&#x5F00;&#x83B7;&#x53D6;&#x4E0B;&#x4E00;&#x6761;&#x6307;&#x4EE4;&#x6240;&#x9700;&#x6570;&#x636E;&#x65F6;&#x9020;&#x6210;&#x7684;&#x7B49;&#x5F85;&#x3002;

int a = 1;
int b = 2;
int c = a + b;

&#x5C06;&#x4E0A;&#x9762;&#x7684;&#x4EE3;&#x7801;&#x7F16;&#x8BD1;&#x6210;Java&#x5B57;&#x8282;&#x7801;&#x6216;&#x751F;&#x6210;&#x673A;&#x5668;&#x6307;&#x4EE4;&#xFF0C;&#x5927;&#x81F4;&#x53EF;&#x89C6;&#x4E3A;&#x5C55;&#x5F00;&#x6210;&#x4E86;&#x4EE5;&#x4E0B;&#x51E0;&#x6B65;&#x52A8;&#x4F5C;&#xFF1A;
&#x5BF9;a&#x8D4B;&#x503C;1                 --1
&#x5BF9;b&#x8D4B;&#x503C;2                 --2
&#x53D6;a&#x7684;&#x503C;                  --3
&#x53D6;b&#x7684;&#x503C;                  --4
&#x5C06;&#x53D6;&#x5230;&#x4E24;&#x4E2A;&#x503C;&#x76F8;&#x52A0;&#x540E;&#x5B58;&#x5165;c  --5
&#x5728;&#x4E0A;&#x9762;5&#x4E2A;&#x52A8;&#x4F5C;&#x4E2D;&#xFF0C;&#x52A8;&#x4F5C;1&#x53EF;&#x80FD;&#x4F1A;&#x548C;&#x52A8;&#x4F5C;2&#x3001;4&#x91CD;&#x6392;&#x5E8F;&#xFF0C;
&#x52A8;&#x4F5C;2&#x53EF;&#x80FD;&#x4F1A;&#x548C;&#x52A8;&#x4F5C;1&#x3001;3&#x91CD;&#x6392;&#x5E8F;&#xFF0C;&#x52A8;&#x4F5C;3&#x53EF;&#x80FD;&#x4F1A;&#x548C;&#x52A8;&#x4F5C;2&#x3001;4&#x91CD;&#x6392;&#x5E8F;&#xFF0C;
&#x52A8;&#x4F5C;4&#x53EF;&#x80FD;&#x4F1A;&#x548C;1&#x3001;3&#x91CD;&#x6392;&#x5E8F;&#x3002;&#x4F46;&#x52A8;&#x4F5C;1&#x548C;&#x52A8;&#x4F5C;3&#x3001;5&#x4E0D;&#x80FD;&#x91CD;&#x6392;&#x5E8F;&#x3002;
&#x52A8;&#x4F5C;2&#x548C;&#x52A8;&#x4F5C;4&#x3001;5&#x4E0D;&#x80FD;&#x91CD;&#x6392;&#x5E8F;&#x3002;&#x56E0;&#x4E3A;&#x5B83;&#x4EEC;&#x4E4B;&#x95F4;&#x5B58;&#x5728;&#x6570;&#x636E;&#x4F9D;&#x8D56;&#x5173;&#x7CFB;&#xFF0C;
&#x4E00;&#x65E6;&#x91CD;&#x6392;&#xFF0C;as-if-serial&#x8BED;&#x4E49;&#x4FBF;&#x65E0;&#x6CD5;&#x4FDD;&#x8BC1;&#x3002;
</code></pre>
<h2 id="as-if-serial-&#x8BED;&#x4E49;"><a name="as-if-serial-&#x8BED;&#x4E49;" class="anchor-navigation-ex-anchor" href="#as-if-serial-&#x8BED;&#x4E49;"><i class="fa fa-link" aria-hidden="true"></i></a>3.7. as-if-serial &#x8BED;&#x4E49;</h2>
<pre><code class="lang-text">&#x6240;&#x6709;&#x7684;&#x52A8;&#x4F5C;&#x90FD;&#x53EF;&#x4EE5;&#x4E3A;&#x4E86;&#x4F18;&#x5316;&#x800C;&#x88AB;&#x91CD;&#x6392;&#x5E8F;&#xFF0C;
&#x4F46;&#x662F;&#x5FC5;&#x987B;&#x4FDD;&#x8BC1;&#x5B83;&#x4EEC;&#x91CD;&#x6392;&#x5E8F;&#x540E;&#x7684;&#x7ED3;&#x679C;&#x548C;&#x7A0B;&#x5E8F;&#x4EE3;&#x7801;&#x672C;&#x8EAB;&#x7684;&#x5E94;&#x6709;&#x7ED3;&#x679C;&#x662F;&#x4E00;&#x81F4;&#x3002;
&#x6240;&#x4EE5;&#xFF0C;&#x91CD;&#x6392;&#x5E8F;&#x4E0D;&#x4F1A;&#x53D1;&#x751F;&#x5728;&#x6709;&#x6570;&#x636E;&#x4F9D;&#x8D56;&#x7684;&#x64CD;&#x4F5C;&#x4E4B;&#x4E2D;&#x3002;
</code></pre>
<h1 id="8&#x5927;&#x539F;&#x5B50;&#x64CD;&#x4F5C;"><a name="8&#x5927;&#x539F;&#x5B50;&#x64CD;&#x4F5C;" class="anchor-navigation-ex-anchor" href="#8&#x5927;&#x539F;&#x5B50;&#x64CD;&#x4F5C;"><i class="fa fa-link" aria-hidden="true"></i></a>4. 8&#x5927;&#x539F;&#x5B50;&#x64CD;&#x4F5C;</h1>
<pre><code class="lang-text">&#x4E3A;&#x4E86;&#x89E3;&#x51B3;&#x4E3B;&#x5185;&#x5B58;&#x548C;&#x5DE5;&#x4F5C;&#x7EBF;&#x7A0B;&#x7684;&#x4E00;&#x81F4;&#x6027;&#x95EE;&#x9898;&#xFF0C;Java&#x5B9A;&#x4E49;&#x4E86;&#x5982;&#x4E0B;&#x539F;&#x5B50;&#x64CD;&#x4F5C;.
1&#x3001; lock &#x9501;&#x5B9A;
&#x4F5C;&#x7528;&#x4E8E;&#x4E3B;&#x5185;&#x5B58;&#xFF0C;&#x628A;&#x53D8;&#x91CF;&#x6807;&#x8BB0;&#x4E3A;&#x4E00;&#x6761;&#x7EBF;&#x7A0B;&#x72EC;&#x5360;&#x72B6;&#x6001;&#x3002;

2&#x3001;unlock &#x89E3;&#x9501;&#x3002;
&#x4F5C;&#x7528;&#x4E8E;&#x4E3B;&#x5185;&#x5B58;&#xFF0C;&#x91CA;&#x653E;&#x540E;&#x7684;&#x53D8;&#x91CF;&#x624D;&#x80FD;&#x88AB;&#x5176;&#x4ED6;&#x7EBF;&#x7A0B;&#x9501;&#x5B9A;&#x3002;

3&#x3001; read &#x8BFB;&#x53D6;
&#x4F5C;&#x7528;&#x4E8E;&#x4E3B;&#x5185;&#x5B58;&#x3002; &#x5C06;&#x53D8;&#x91CF;&#x7684;&#x503C;&#x4ECE;&#x4E3B;&#x5185;&#x5B58;&#x4F20;&#x8F93;&#x5230;&#x5DE5;&#x4F5C;&#x5185;&#x5B58;&#x4E2D;&#x3002;

4&#x3001;load &#x8F7D;&#x5165;
&#x4F5C;&#x7528;&#x4E8E;&#x5DE5;&#x4F5C;&#x5185;&#x5B58;&#x3002;&#x5C06;&#x4ECE;&#x4E3B;&#x5185;&#x5B58;&#x4E2D;&#x5F97;&#x5230;&#x7684;&#x53D8;&#x91CF;&#x503C;&#x653E;&#x5165;&#x5DE5;&#x4F5C;&#x5185;&#x5B58;&#x7684;&#x53D8;&#x91CF;&#x526F;&#x672C;&#x4E2D;&#x3002;

5&#x3001; use &#x4F7F;&#x7528;&#x3002;
&#x4F5C;&#x7528;&#x4E8E;&#x5DE5;&#x4F5C;&#x5185;&#x5B58;&#x3002; &#x5C06;&#x5DE5;&#x4F5C;&#x5185;&#x5B58;&#x4E2D;&#x7684;&#x53D8;&#x91CF;&#x7684;&#x503C;&#x4F20;&#x9012;&#x7ED9;&#x6267;&#x884C;&#x5F15;&#x64CE;&#x3002;

6&#x3001;assign &#x8D4B;&#x503C;
&#x4F5C;&#x7528;&#x4E8E;&#x5DE5;&#x4F5C;&#x5185;&#x5B58;&#x3002;&#x5C06;&#x6267;&#x884C;&#x5F15;&#x64CE;&#x4F20;&#x9012;&#x8FC7;&#x6765;&#x7684;&#x503C;&#x8D4B;&#x503C;&#x7ED9;&#x5DE5;&#x4F5C;&#x5185;&#x5B58;&#x4E2D;&#x7684;&#x53D8;&#x91CF;&#x526F;&#x672C;&#x3002;

7&#x3001;store &#x5B58;&#x50A8;
&#x4F5C;&#x7528;&#x4E8E;&#x5DE5;&#x4F5C;&#x5185;&#x5B58;&#x3002; &#x5C06;&#x5DE5;&#x4F5C;&#x5185;&#x5B58;&#x4E2D;&#x7684;&#x53D8;&#x91CF;&#x503C;&#x4F20;&#x9012;&#x5230;&#x4E3B;&#x5185;&#x5B58;&#x3002;

8&#x3001;write &#x5199;&#x5165;
&#x4F5C;&#x7528;&#x4E8E;&#x4E3B;&#x5185;&#x5B58;&#x3002;&#x5C06;&#x4ECE;&#x5DE5;&#x4F5C;&#x5185;&#x5B58;&#x4E2D;&#x4F20;&#x9012;&#x8FC7;&#x6765;&#x7684;&#x503C; &#x8D4B;&#x503C;&#x7ED9;&#x4E3B;&#x5185;&#x5B58;&#x7684;&#x53D8;&#x91CF;&#x3002;
</code></pre>
<footer class="page-footer"><span class="copyright">( no Copyright&#xFF0C;enjoy youself ! ) all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">The file was updated at :
2022-04-04 10:49:02
</span></footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="类加载机制.html" class="navigation navigation-prev " aria-label="Previous page: 类加载机制">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="GC机制.html" class="navigation navigation-next " aria-label="Next page: GC机制">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"内存模型","level":"1.11.5","depth":2,"next":{"title":"GC机制","level":"1.11.6","depth":2,"path":"chinese/java基础/GC机制.md","ref":"chinese/java基础/GC机制.md","articles":[]},"previous":{"title":"类加载机制","level":"1.11.4","depth":2,"path":"chinese/java基础/类加载机制.md","ref":"chinese/java基础/类加载机制.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-search","search-plus","todo","anchor-navigation-ex","copy-code-button","fontsettings","tbfed-pagefooter","local-video","splitter","expandable-chapters","favicon","theme-comscore","local-video"],"styles":{"website":"styles/website.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"( no Copyright，enjoy youself ! )","modify_label":"The file was updated at :","modify_format":"YYYY-MM-DD HH:mm:ss"},"todo":{},"splitter":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"family":"sans","size":2,"theme":"white"},"highlight":{},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":true},"favicon":{"shortcut":"assets/images/favicon.ico","bookmark":"assets/images/favicon.ico"},"theme-comscore":{},"local-video":{},"copy-code-button":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"expandable-chapters":{},"search-plus":{}},"theme":"default","author":"Aivin","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Aivin开发笔记","language":"zh-hans","gitbook":"*","description":"Aivin开发笔记"},"file":{"path":"chinese/java基础/内存模型.md","mtime":"2022-04-04T02:49:02.763Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2022-04-04T03:47:09.782Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-search-plus/jquery.mark.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-plus/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-copy-code-button/toggle.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-local-video/video.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

